Skip to content

Conversation

deanm0000
Copy link
Contributor

@deanm0000 deanm0000 commented Mar 20, 2025

Which issue does this PR close?

Closes #1075

Rationale for this change

To improve ergonomics of the API by providing a quicker way of accessing columns using the __getattr__ method of classes. Using the __call__ method, the original behavior is maintained, this is only additive.
Now this is possible

from datafusion import col as c

my_a_column=c.a
my_banana_column=c.banana

What changes are included in this PR?

A new col.py file with the class. I removed the col and column function from __init__ and imported col and column from col.py. I added a test that duplicates another test but uses the new syntax.

Are there any user-facing changes?

Only optional ones as mentioned above.

No breaking changes.

Copy link
Member

@timsaucer timsaucer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clever PR. Thank you for the contribution! I'm sorry it took so long to get reviewed.

@timsaucer timsaucer merged commit 00dea11 into apache:main Apr 27, 2025
@deanm0000
Copy link
Contributor Author

I got it from polars, not clever on my part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Col class instead of just col function to use __getattr__ method

2 participants